﻿#ifndef __SS_MSG_PROCESSOR_H__
#define __SS_MSG_PROCESSOR_H__
#include "../ssBaseDefine.h"
#include "ssNetMsgHead.h"

namespace StarSeeker
{

class ssMsgProcessor
{
public:
	typedef void (ssMsgProcessor::*pHandelMessage)(u32 msgId, ulint param1, ulint param2);

	ssMsgProcessor()
	{
	}
	virtual ~ssMsgProcessor()
	{
	}

	virtual void HandelMessage(u32 msgId, ulint param1, ulint param2) = 0;

};

class ssNetMsgProcessor : public ssMsgProcessor
{
public:
	ssNetMsgProcessor()
	{
	}
	~ssNetMsgProcessor()
	{
	}

protected:
	void HandelMessage(u32 msgId, ulint param1, ulint param2)
	{
		ssNetMsgHead* head = (ssNetMsgHead*)param2;
		char* buf = (char*)param2;
		if (head && head->m_dwLen >= MSG_HEADER_LEN && head->m_dwLen < MSG_MAX_SIZE)
		{
			HandelNetMessage(msgId, param1, head, buf + MSG_HEADER_LEN, head->m_dwLen - MSG_HEADER_LEN);
		}
	}

	virtual void HandelNetMessage(u32 msgId, u32 connectId, ssNetMsgHead* head, const char* data, u32 len) = 0;
};

}
#endif
